/**
 * Copyright (c) 2000-2012 Liferay, Inc. All rights reserved.
 *
 * This library is free software; you can redistribute it and/or modify it under
 * the terms of the GNU Lesser General Public License as published by the Free
 * Software Foundation; either version 2.1 of the License, or (at your option)
 * any later version.
 *
 * This library is distributed in the hope that it will be useful, but WITHOUT
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
 * FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
 * details.
 */

package com.fl.uploadfile.model.impl;

import com.fl.uploadfile.model.UploadFile;
import com.fl.uploadfile.model.UploadFileModel;

import com.liferay.portal.kernel.bean.AutoEscapeBeanHandler;
import com.liferay.portal.kernel.util.GetterUtil;
import com.liferay.portal.kernel.util.ProxyUtil;
import com.liferay.portal.kernel.util.StringBundler;
import com.liferay.portal.kernel.util.StringPool;
import com.liferay.portal.model.CacheModel;
import com.liferay.portal.model.impl.BaseModelImpl;
import com.liferay.portal.service.ServiceContext;

import com.liferay.portlet.expando.model.ExpandoBridge;
import com.liferay.portlet.expando.util.ExpandoBridgeFactoryUtil;

import java.io.Serializable;

import java.sql.Types;

/**
 * The base model implementation for the UploadFile service. Represents a row in the &quot;TK_UploadFile&quot; database table, with each column mapped to a property of this class.
 *
 * <p>
 * This implementation and its corresponding interface {@link com.fl.uploadfile.model.UploadFileModel} exist only as a container for the default property accessors generated by ServiceBuilder. Helper methods and all application logic should be put in {@link UploadFileImpl}.
 * </p>
 *
 * @author Manisha
 * @see UploadFileImpl
 * @see com.fl.uploadfile.model.UploadFile
 * @see com.fl.uploadfile.model.UploadFileModel
 * @generated
 */
public class UploadFileModelImpl extends BaseModelImpl<UploadFile>
	implements UploadFileModel {
	/*
	 * NOTE FOR DEVELOPERS:
	 *
	 * Never modify or reference this class directly. All methods that expect a upload file model instance should use the {@link com.fl.uploadfile.model.UploadFile} interface instead.
	 */
	public static final String TABLE_NAME = "TK_UploadFile";
	public static final Object[][] TABLE_COLUMNS = {
			{ "fileUploadId", Types.BIGINT },
			{ "fileEntryId", Types.BIGINT },
			{ "title", Types.VARCHAR },
			{ "description", Types.VARCHAR },
			{ "size_", Types.BIGINT }
		};
	public static final String TABLE_SQL_CREATE = "create table TK_UploadFile (fileUploadId LONG not null primary key,fileEntryId LONG,title VARCHAR(75) null,description VARCHAR(75) null,size_ LONG)";
	public static final String TABLE_SQL_DROP = "drop table TK_UploadFile";
	public static final String ORDER_BY_JPQL = " ORDER BY uploadFile.title ASC";
	public static final String ORDER_BY_SQL = " ORDER BY TK_UploadFile.title ASC";
	public static final String DATA_SOURCE = "liferayDataSource";
	public static final String SESSION_FACTORY = "liferaySessionFactory";
	public static final String TX_MANAGER = "liferayTransactionManager";
	public static final boolean ENTITY_CACHE_ENABLED = GetterUtil.getBoolean(com.liferay.util.service.ServiceProps.get(
				"value.object.entity.cache.enabled.com.fl.uploadfile.model.UploadFile"),
			true);
	public static final boolean FINDER_CACHE_ENABLED = GetterUtil.getBoolean(com.liferay.util.service.ServiceProps.get(
				"value.object.finder.cache.enabled.com.fl.uploadfile.model.UploadFile"),
			true);
	public static final boolean COLUMN_BITMASK_ENABLED = false;
	public static final long LOCK_EXPIRATION_TIME = GetterUtil.getLong(com.liferay.util.service.ServiceProps.get(
				"lock.expiration.time.com.fl.uploadfile.model.UploadFile"));

	public UploadFileModelImpl() {
	}

	public long getPrimaryKey() {
		return _fileUploadId;
	}

	public void setPrimaryKey(long primaryKey) {
		setFileUploadId(primaryKey);
	}

	public Serializable getPrimaryKeyObj() {
		return new Long(_fileUploadId);
	}

	public void setPrimaryKeyObj(Serializable primaryKeyObj) {
		setPrimaryKey(((Long)primaryKeyObj).longValue());
	}

	public Class<?> getModelClass() {
		return UploadFile.class;
	}

	public String getModelClassName() {
		return UploadFile.class.getName();
	}

	public long getFileUploadId() {
		return _fileUploadId;
	}

	public void setFileUploadId(long fileUploadId) {
		_fileUploadId = fileUploadId;
	}

	public long getFileEntryId() {
		return _fileEntryId;
	}

	public void setFileEntryId(long fileEntryId) {
		_fileEntryId = fileEntryId;
	}

	public String getTitle() {
		if (_title == null) {
			return StringPool.BLANK;
		}
		else {
			return _title;
		}
	}

	public void setTitle(String title) {
		_title = title;
	}

	public String getDescription() {
		if (_description == null) {
			return StringPool.BLANK;
		}
		else {
			return _description;
		}
	}

	public void setDescription(String description) {
		_description = description;
	}

	public long getSize() {
		return _size;
	}

	public void setSize(long size) {
		_size = size;
	}

	@Override
	public UploadFile toEscapedModel() {
		if (_escapedModelProxy == null) {
			_escapedModelProxy = (UploadFile)ProxyUtil.newProxyInstance(_classLoader,
					_escapedModelProxyInterfaces,
					new AutoEscapeBeanHandler(this));
		}

		return _escapedModelProxy;
	}

	@Override
	public ExpandoBridge getExpandoBridge() {
		if (_expandoBridge == null) {
			_expandoBridge = ExpandoBridgeFactoryUtil.getExpandoBridge(0,
					UploadFile.class.getName(), getPrimaryKey());
		}

		return _expandoBridge;
	}

	@Override
	public void setExpandoBridgeAttributes(ServiceContext serviceContext) {
		getExpandoBridge().setAttributes(serviceContext);
	}

	@Override
	public Object clone() {
		UploadFileImpl uploadFileImpl = new UploadFileImpl();

		uploadFileImpl.setFileUploadId(getFileUploadId());
		uploadFileImpl.setFileEntryId(getFileEntryId());
		uploadFileImpl.setTitle(getTitle());
		uploadFileImpl.setDescription(getDescription());
		uploadFileImpl.setSize(getSize());

		uploadFileImpl.resetOriginalValues();

		return uploadFileImpl;
	}

	public int compareTo(UploadFile uploadFile) {
		int value = 0;

		value = getTitle().compareTo(uploadFile.getTitle());

		if (value != 0) {
			return value;
		}

		return 0;
	}

	@Override
	public boolean equals(Object obj) {
		if (obj == null) {
			return false;
		}

		UploadFile uploadFile = null;

		try {
			uploadFile = (UploadFile)obj;
		}
		catch (ClassCastException cce) {
			return false;
		}

		long primaryKey = uploadFile.getPrimaryKey();

		if (getPrimaryKey() == primaryKey) {
			return true;
		}
		else {
			return false;
		}
	}

	@Override
	public int hashCode() {
		return (int)getPrimaryKey();
	}

	@Override
	public void resetOriginalValues() {
	}

	@Override
	public CacheModel<UploadFile> toCacheModel() {
		UploadFileCacheModel uploadFileCacheModel = new UploadFileCacheModel();

		uploadFileCacheModel.fileUploadId = getFileUploadId();

		uploadFileCacheModel.fileEntryId = getFileEntryId();

		uploadFileCacheModel.title = getTitle();

		String title = uploadFileCacheModel.title;

		if ((title != null) && (title.length() == 0)) {
			uploadFileCacheModel.title = null;
		}

		uploadFileCacheModel.description = getDescription();

		String description = uploadFileCacheModel.description;

		if ((description != null) && (description.length() == 0)) {
			uploadFileCacheModel.description = null;
		}

		uploadFileCacheModel.size = getSize();

		return uploadFileCacheModel;
	}

	@Override
	public String toString() {
		StringBundler sb = new StringBundler(11);

		sb.append("{fileUploadId=");
		sb.append(getFileUploadId());
		sb.append(", fileEntryId=");
		sb.append(getFileEntryId());
		sb.append(", title=");
		sb.append(getTitle());
		sb.append(", description=");
		sb.append(getDescription());
		sb.append(", size=");
		sb.append(getSize());
		sb.append("}");

		return sb.toString();
	}

	public String toXmlString() {
		StringBundler sb = new StringBundler(19);

		sb.append("<model><model-name>");
		sb.append("com.fl.uploadfile.model.UploadFile");
		sb.append("</model-name>");

		sb.append(
			"<column><column-name>fileUploadId</column-name><column-value><![CDATA[");
		sb.append(getFileUploadId());
		sb.append("]]></column-value></column>");
		sb.append(
			"<column><column-name>fileEntryId</column-name><column-value><![CDATA[");
		sb.append(getFileEntryId());
		sb.append("]]></column-value></column>");
		sb.append(
			"<column><column-name>title</column-name><column-value><![CDATA[");
		sb.append(getTitle());
		sb.append("]]></column-value></column>");
		sb.append(
			"<column><column-name>description</column-name><column-value><![CDATA[");
		sb.append(getDescription());
		sb.append("]]></column-value></column>");
		sb.append(
			"<column><column-name>size</column-name><column-value><![CDATA[");
		sb.append(getSize());
		sb.append("]]></column-value></column>");

		sb.append("</model>");

		return sb.toString();
	}

	private static ClassLoader _classLoader = UploadFile.class.getClassLoader();
	private static Class<?>[] _escapedModelProxyInterfaces = new Class[] {
			UploadFile.class
		};
	private long _fileUploadId;
	private long _fileEntryId;
	private String _title;
	private String _description;
	private long _size;
	private transient ExpandoBridge _expandoBridge;
	private UploadFile _escapedModelProxy;
}